package sg4c.frontend.command;

import java.awt.Color;
import java.io.IOException;
import sg4c.frontend.GraphicsContext;
import sg4c.protocol.DataInputProtocol;

public class SetFillColor implements GraphicsCommand {

    private final Color color;
    
    public SetFillColor(int r, int g, int b, int alpha) {
        color = new Color(r, g, b, alpha);
    }

    public void execute(GraphicsContext context) {
        context.setFillColor(color);
    }
    public static final Factory factory = new Factory() {

        public GraphicsCommand parse(DataInputProtocol in) throws IOException {
            int r = in.readInt();
            int g = in.readInt();
            int b = in.readInt();
            int alpha = in.readInt();
            return new SetFillColor(r, g, b, alpha);
        }
    };
}
